package com.qf.util;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

public class ElasticsearchUtil {

    public static RestHighLevelClient client(){
        //1. 设置连接ES的信息
        HttpHost httpHost = new HttpHost("192.168.199.109",9200);

        //2. 封装到RestClientBuilder对象中
        RestClientBuilder clientBuilder = RestClient.builder(httpHost);

        //3. 构建RestHighLevelClient对象，注入RestClientBuilder
        RestHighLevelClient client = new RestHighLevelClient(clientBuilder);

        //4. 返回
        return client;
    }
}
